<?php
/**
 * Created by PhpStorm.
 * User: C。
 * Date: 2019/8/13
 * Time: 9:04
 */
namespace app\home\controller;

use app\common\model\Shinian as ShinianModel;

/**
 * 十念定课控制器
 * Class Shinian
 * @package app\home\controller
 */
class Shinian extends Base
{
    /**
     * [postAdd  添加]
     * @param
     * @return json
     * @author [C。]
     */
    public function add()
    {
        $model = new ShinianModel;
        $param = input('param.');
        $mem = $this->user;
        try{
            $param['mid'] = $mem['id'];
            if(empty($param['id'])){
                $param['gointime'] = strtotime($param['gointime']);
                $id = $model->addData($param);
                add_quality($mem['id'],13,$mem['quality'],2);
            }else{
                if(!empty($param['leavetime'])){
                    $param['leavetime'] = strtotime($param['leavetime']);
                }
                $id = $model->editData($param);
            }
        }catch(\Exception $e){
            systembug($e->getMessage(),2,$this->url);
            return admin_json(-1, '添加失败'.$e->getMessage());
        }
        return admin_json(1,'添加成功',$id);
    }
}